{% set permissions = sub_permissions('admin_v2') %}

{% if permissions|default(null) %}
  {% if menu|default(null) %}
    {% set rootMenu = nav_permission(menu) %}
  {% else %}
    {% set rootMenu = permission('admin_v2') %}
  {% endif %}

<ul class="cd-tabs ct-layout-navbar_ul">
  <li {% if adminV2Homepage|default(null) %}class="active"{% endif %} id="nav_admin_v2">
    <a title="{{ 'admin_v2.homepage.overview'|trans }}" href="{{ path('admin_v2') }}">{{ 'admin_v2.homepage.overview'|trans }}</a>
  </li>
  {% for m in permissions if not m.visible is defined or eval_expression(m.visible) %}
    {% set tabMenu = first_child_permission(first_child_permission(first_child_permission(m, true, false), true, false), true, false) %}
    {% if tabMenu %}
      <li class="{% if menu and m.code == rootMenu.code|default(null) %}active{% endif %} {% if m.code == 'admin_v2_cloud_center' %}application-icon{% endif %} {{ m.class|default('') }}" id="nav_{{ m.code }}">
        <a
          title="{{ m.name|trans({}, 'menu') }}"
          href="{{ permission_path(tabMenu) }}"
          {% if m.blank|default(false)%}
            target="_blank"
          {% endif %}
        >
          <img src="{{ asset('static-dist/app/img/admin-v2/app.png') }}" srcset="{{ asset('static-dist/app/img/admin-v2/app.png') }} 1x, {{ asset('static-dist/app/img/admin-v2/app@2x.png') }} 2x"><span>{{ m.name|trans({}, 'menu') }}</span>
        </a>
      </li>
    {% endif %}
  {% endfor %}
</ul>
{% endif %}
